﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.Objects;

namespace MINERP.DAL.InfoConfig
{
    public class CostTypeDAL:DALBase
    {

        private static ObjectQuery<tb_CostType> GetCostTypes()
        {
            return DataEntites.tb_CostType;
        }

        public static List<tb_CostType> GetCostTypeList()
        {
            List<tb_CostType> list = new List<tb_CostType>();
            foreach (var item in GetCostTypes())
            {
                list.Add(item);
            }
            return list;
        }

        public static tb_CostType GetCostTypeObj(int id)
        {
            return DataEntites.tb_CostType.First(c => c.CostTypeId == id);
        }

        public static tb_CostType GetCostTypeObj(string name)
        {
            return DataEntites.tb_CostType.First(c => c.TypeName ==name);
        }

        public static void Add(tb_CostType obj)
        {
            DataEntites.AddTotb_CostType(obj);
            DataEntites.SaveChanges();
        }

        public static void Update()
        {
            DataEntites.SaveChanges();
        }

        public static void Delete(tb_CostType obj)
        {
            DataEntites.DeleteObject(obj);
            DataEntites.SaveChanges();
        }
    }
}
